﻿/****************************************************************************************************
	Copyright (C) 2010 RapidWebDev Organization (http://rapidwebdev.org)
	Author: Eunge, Legal Name: Jian Liu, Email: eunge.liu@RapidWebDev.org

	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 2 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ****************************************************************************************************/

using System;
using System.Globalization;
using System.Net;
using System.ServiceModel.Web;
using System.Runtime.Serialization;
using System.Security.Permissions;
using System.Resources;
using System.Reflection;
using BaoJianSoft.Common.Properties;

namespace BaoJianSoft.Common.Web
{
    /// <summary>
    /// Restful Not Found exception.
    /// </summary>
    [Serializable]
    public class NotFoundException : RestfulException
    {
        /// <summary>
        /// Default constructor.
        /// </summary>
        public NotFoundException()
            : this(Resources.NotFound)
        {
        }

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="msg">Message to include in the exception.</param>
        public NotFoundException(string msg)
			: base(HttpStatusCode.NotFound, msg)
        {
        }

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="ex">Inner exception.</param>
        public NotFoundException(Exception ex)
			: base(HttpStatusCode.NotFound,
                   String.Format(CultureInfo.InvariantCulture, "{0} {1}", Resources.BadRequest, ex.Message),
                   ex)
        {
        }

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="msg">Message to include in the exception.</param>
        /// <param name="ex">Inner exception.</param>
        public NotFoundException(string msg, Exception ex)
			: base(HttpStatusCode.NotFound, msg, ex)
        {
        }


        /// <summary>
        /// Constructor used for serialization
        /// </summary>
        /// <param name="info">SerializationInfo object</param>
        /// <param name="context">StreamingContext object</param>
        protected NotFoundException(SerializationInfo info, StreamingContext context)
            : base(info, context)
        {
        }
    }
}

